import request from '@/utils/request'

// 查询作物类别列表
export function listCropCategory(query) {
  return request({
    url: '/insect/cropcategory/list',
    method: 'get',
    params: query
  })
}

// 查询作物类别详细
export function getCropCategory(id) {
  return request({
    url: '/insect/cropcategory/' + id,
    method: 'get'
  })
}

// 新增作物类别
export function addCropCategory(data) {
  return request({
    url: '/insect/cropcategory',
    method: 'post',
    data: data
  })
}

// 修改作物类别
export function updateCropCategory(data) {
  return request({
    url: '/insect/cropcategory',
    method: 'put',
    data: data
  })
}

// 删除作物类别
export function delCropCategory(id) {
  return request({
    url: '/insect/cropcategory/' + id,
    method: 'delete'
  })
}

// 导出作物类别
export function exportCropCategory(query) {
  return request({
    url: '/insect/cropcategory/export',
    method: 'get',
    params: query
  })
}

// 获取所有作物名称列表
export function getAllCropNames() {
  return request({
    url: '/insect/cropcategory/getAllCropNames',
    method: 'get'
  })
}

// 根据作物名称获取病虫害列表
export function getDiseasesByCrop(cropName) {
  return request({
    url: '/insect/diseaselabel/getDiseasesByCrop',
    method: 'get',
    params: { cropName }
  })
}
